package com.example.lvsuo.mapper;

import com.example.lvsuo.entity.CaseLaw;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.lvsuo.entity.vo.CaseLawVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 案件/我的案件    利益冲突审查    新增委托人    登记立案信息 Mapper 接口
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
public interface CaseLawMapper extends BaseMapper<CaseLaw> {

    /**
     * 查询利益冲突
     * @param caseOppositeCardnum
     * @param cardnum
     * @return
     */
    @Select("select cl.*,c.cardnum from case_law cl inner join client c on cl.client_id = c.id and (cl.case_opposite_cardnum=#{cardnum} or c.cardnum=#{caseOppositeCardnum})")
    List<Map<String,Object>> queryCaseLaw(@Param("caseOppositeCardnum") String caseOppositeCardnum, @Param("cardnum") String cardnum);

    /**
     * 查询案号
     * @return
     */
    @Select("select max(id) from case_law")
    String queryCaseNo();

    @Select("SELECT LAST_INSERT_ID()")
    String queryId();


    List<CaseLawVo> querySenior(CaseLawVo c);

    void upCaseLaw(CaseLawVo c);

    List<CaseLawVo> getCaseLaw(CaseLawVo caseLawVo);
    
    @Select("select cl.id,GROUP_CONCAT(c.case_attorney,',',h.emp_name) case_attorney from cw_performancesplit c inner join case_law cl on c.case_Law_id=cl.id inner join  hr_emp h on c.hr_emp_id=h.id where cl.id=#{id}  group by cl.id")
    List<CaseLawVo> queryAttorney(CaseLawVo c);


}
